#ifndef PARSER_H
#define PARSER_H

#include <qstring.h>
#include <QtXml/QXmlDefaultHandler>
#include <QtXml/QXmlAttributes>
#include <QtXml>

class Parser : public QXmlDefaultHandler
{
public:

    Parser(QString p_filename);

    /** given by the framework from qxml. Called when parsing the xml-document starts. */
    bool startDocument();

     /** given by the framework from qxml. Called when the reader occurs an open tag (e.g. \<b\> ) */
    bool startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& att );

    QDomNodeList elementsByTagName(const QString &tag);
    static QDomNodeList elementsByTagName(const QByteArray data,const QString tag, QString *errorStr = 0)
    {
        QDomDocument doc( "myDocument" );

        errorStr != NULL ? doc.setContent( data,false,errorStr ) :doc.setContent( data,false );
        //qDebug() << data;
        QDomElement docElement = doc.documentElement();

        return docElement.elementsByTagName(tag);
    }

private:
    QString filename;

   };


   #endif
